package com.itheima.service.impl;

import com.itheima.mapper.UserMapper;
import com.itheima.pojo.PageResult;
import com.itheima.pojo.User;
import com.itheima.queryParams.UserQueryParam;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public PageResult getUserList(UserQueryParam userQueryParam) {
//        PageHelper.startPage(userQueryParam.getPage(),userQueryParam.getPageSize());
//        List<User> userList = userMapper.getUserList(userQueryParam);
//        Page<User> list = (Page<User>) userList;
//        return new PageResult(list.getTotal(),list.getResult());
        long total = userMapper.count(userQueryParam);
        List<User> list = userMapper.getUserList(userQueryParam);
        return new PageResult(total,list);
    }
}
